package com.cloudptt.api.product.func.voice;

import android.content.Context;

import com.cloudptt.api.product.ProductOperator;
import com.cloudptt.api.product.func.IFunc;
import com.cloudptt.api.product.log.Log;
import com.mcptt.config.model.McIdInfo;
import com.mcptt.config.model.BootStrapSvrInfo;

public class VoiceReportFunc implements VoiceReportListener,IFunc
{

	public final static String Log_Key = "VoiceReportFunc";
//	private Context ctx = null;
//	private VoiceReportOperator operator = null;

	private VoiceReportBroadcast broadcast = null;
	private VoiceReport voiceReport = null;


	public VoiceReportFunc(Context ctx,ProductOperator operator,String lanType)
	{
		Log.d(Log_Key, "VoiceReportAgent");
		this.voiceReport = new VoiceReport(ctx,lanType,operator);
		this.broadcast = new VoiceReportBroadcast(ctx,this);
		this.voiceReport.setOperator(operator.getVrOperator());
		this.voiceReport.start();
		
	}
	
	public void receiveVoiceReport(String voiceReportStr)
	{
		Log.d(Log_Key, "receiveVoiceReport");
		if(this.voiceReport != null)
		{
//			this.voiceReport.addVoiceMsg(voiceReportStr);
		}
	}

	@Override
	public void onLogined(McIdInfo mcIdInfo, BootStrapSvrInfo info, boolean isLoginSuc)
	{
		// TODO Auto-generated method stub
		
	}
	@Override
	public void onPublishResult(int publishResult)
	{}
	@Override
	public void onSubscribeCmsGmsResult(boolean isSuc,int mcType)
	{}
	@Override
	public void doNetworkChange(boolean isConn)
	{
		Log.d(Log_Key, "networkOffline isConn = " + isConn);
	}
	@Override
	public void doForceDetach()
	{
		Log.d(Log_Key, "doForceDetach");
	}
	@Override
	public void doLogout() {
		Log.d(Log_Key, "doLogout");
	}
	public void doExit()
	{
		Log.d(Log_Key, "doExit");
		this.broadcast.clearResource();
		
		this.voiceReport.stopThread();
		this.voiceReport.interrupt();
		
		this.voiceReport = null;
		this.broadcast = null;
	}

	@Override
	public void onLanChange(String lanType) {
		// TODO Auto-generated method stub
		this.voiceReport.setLanType(lanType);
	}

	@Override
	public void onKeepAlive(boolean isconnected) {
		// TODO Auto-generated method stub
		
	}
	
}
